import unittest
from parameterized import parameterized
from myList import MyList


class TestMySplice(unittest.TestCase):
    @classmethod
    def setUpClass(cls):
        pass

    @classmethod
    def tearDownClass(cls):
        pass

    # 测试数据存放在列表中, 列表中每组数据以元组的形式存放
    @parameterized.expand([
        ([1, 2, 3, 4, 5, 6], 2, 3, [1, 2, 6]),
        (['a', 'b', 'c', 'd'], 1, 2, ['a', 'd'])
    ])
    def testCases(self, testList, index, count, expList):
        ml = MyList(testList)
        actList = ml.mySplice(index, count)
        self.assertEqual(expList, actList)


if __name__ == '__main__':
    # unittestdemo.main()
    suite = unittest.TestSuite()
    testCases = unittest.TestLoader().loadTestsFromTestCase(TestMySplice)
    suite.addTest(test=testCases)
    r = unittest.TestResult()
    suite.run(result=r)
    print(r.__dict__)
